Skip to content

Conversation

@Mnehmos
Copy link
Contributor

@Mnehmos Mnehmos commented Jun 6, 2025

Related GitHub Issue

Closes: #4199

Description

This pull request re-implements the changes from the original PR #4385.

The primary change is a fix for a race condition in the DiffViewProvider that could prevent the diff editor from opening reliably. The previous implementation used onDidChangeActiveTextEditor, which was not always triggered correctly. This has been replaced with a more robust approach that listens for onDidChangeTabGroups and polls for the diff tab's existence, ensuring the editor is resolved correctly even on slower systems.

All debugging console.log statements and a superfluous test file have been removed from the original changes.

Test Procedure

  1. Use Roo to generate a change for a file, which will trigger the diff view.
  2. Confirm that the diff editor opens consistently without timing out.
  3. To simulate a race condition, you can add a delay or perform other actions while the diff view is opening. The new implementation should handle this gracefully.

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Not applicable. This change fixes a race condition and has no visual component.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This PR is a recreation of #4385 after the original branch was accidentally deleted.

Get in Touch

Mnehmos


Important

Fixes race condition in DiffViewProvider by changing event listener and adding polling, ensuring reliable diff editor opening.

  • Behavior:
    • Fixes race condition in DiffViewProvider by replacing onDidChangeActiveTextEditor with onDidChangeTabGroups and adding polling for diff tab existence.
    • Ensures diff editor opens reliably, even on slower systems.
  • Code Cleanup:
    • Removes debugging console.log statements from DiffViewProvider.

This description was created by Ellipsis for 2321243. You can customize this summary. It will automatically update as commits are pushed.

@Mnehmos Mnehmos requested review from cte, jr and mrubens as code owners June 6, 2025 00:43
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jun 6, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 6, 2025
@daniel-lxs daniel-lxs changed the title fix(4385): re-apply changes from PR 4385 fix: resolve diff editor race condition in multi-monitor setups Jun 7, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Mnehmos, Great fix! I can confirm that it works, I left a couple of minor suggestions that might be worth looking into.

Let me know what you think

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 7, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 7, 2025
No async / await: We don't need to await the timeout. We just want to schedule checkAndResolve to run in the future, not pause the entire function. setTimeout does this perfectly on its own.
No if Statement: The confusing if statement is gone. We are no longer checking the return value because we don't need to do anything with it in this specific spot. The primary purpose here is just to trigger the check.
Clear Intent: The corrected code is much clearer. Its only job is to kick off the checkAndResolve function after 100ms. This acts as a simple, manual trigger to supplement the main onDidChangeTabGroups event listener, which is the more robust part of the fix.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 7, 2025
- Add proper handling for checkAndResolve() return value in setTimeout callback
- Enhance tab group change listener to handle boolean return value appropriately
- Add debug logging for better troubleshooting of diff editor opening issues
- Maintain all existing functionality while addressing code review feedback

Addresses review feedback from Daniel in PR RooCodeInc#4394 regarding incomplete
conditional handling around line 484.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 10, 2025
@Mnehmos Mnehmos closed this Jun 12, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
@Mnehmos Mnehmos deleted the 4385-diff-editor-fix branch June 12, 2025 02:02
daniel-lxs pushed a commit that referenced this pull request Jun 13, 2025
- Add proper handling for checkAndResolve() return value in setTimeout callback
- Enhance tab group change listener to handle boolean return value appropriately
- Add debug logging for better troubleshooting of diff editor opening issues
- Maintain all existing functionality while addressing code review feedback

Addresses review feedback from Daniel in PR #4394 regarding incomplete
conditional handling around line 484.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Changes Requested size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Roo Code fails to open diff editor in specific VS Code contexts

2 participants